package com.example.yunbiji0314.service.iml;

import com.example.yunbiji0314.dao.ArticleDao;
import com.example.yunbiji0314.pojo.Article;
import com.example.yunbiji0314.service.ArticleService;
import com.example.yunbiji0314.util.PageUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ArticleServiceImpl implements ArticleService {

    @Autowired
    private ArticleDao articleDao;
    @Override
    public PageInfo<Article> findByUserId(PageUtil pageUtil) {
        //设置分页参数
        PageHelper.startPage(pageUtil.getPageNum(), pageUtil.getPageSize());
        //获取用户id
        Integer object = (Integer) pageUtil.getObject();
        //查数据
        List<Article> byUserId = articleDao.findByUserId(object);
        //引用分页插件
        PageInfo<Article> categoryPageInfo = new PageInfo<>(byUserId);
        return categoryPageInfo;
    }

    @Override
    public int deleted(Integer id) {
        return articleDao.delete(id);
    }

    @Override
    public Article findById(Integer id) {
        return articleDao.findById(id);
    }

    @Override
    public int zengarticle(Article article) {
        return articleDao.zengarticle(article);
    }

    @Override
    public int update(Article article) {
        return articleDao.update(article);
    }

    @Override
    public List<Article> findByUserId02(Integer id) {
        return articleDao.findByUserId02(id);
    }

    @Override
    public List<Article> chabyid(Integer id) {
        return articleDao.chabyid(id);
    }

}
